package taskmanager;

public class Main {
  public static void main(String[] args) throws InterruptedException {

    String[] allIps = {"A", "B", "C", "D", "E"};

    TaskManager tm = new TaskManager(allIps);

    // add a instant task, the source side is G, the target side is B, the file to be transmit is
    // file1.
    // for now, the source side is useless.
    tm.addTask(TaskFactory.createTask("G", "B", "file1.txt", "", 0));

    // add a timing task, the task will start at the time according to the 4th parameter.
    // if the time is before the current time, this task will start immediately as the instant task.
    tm.addTask(TaskFactory.createTask("G", "E", "test9", "2015/10/23 18:23:10", 1));

    // add a period task, the task will run period at a frequence of 40 seconds according to the 4th
    // parameter.
    tm.addTask(TaskFactory.createTask("G", "B", "fileP", "40", 2));


    // other task for testing...
    tm.addTask(TaskFactory.createTask("G", "B", "test2.txt", "", 0));
    tm.addTask(TaskFactory.createTask("G", "B", "test3.txt", "", 0));
    tm.addTask(TaskFactory.createTask("G", "B", "test4.txt", "", 0));
    tm.addTask(TaskFactory.createTask("G", "B", "test5.txt", "", 0));
    tm.addTask(TaskFactory.createTask("G", "C", "test6.txt", "", 0));
    tm.addTask(TaskFactory.createTask("G", "D", "test7", "", 0));
    tm.addTask(TaskFactory.createTask("G", "D", "test8", "", 0));
    tm.addTask(TaskFactory.createTask("G", "E", "test11.txt", "", 0));

    tm.addTask(TaskFactory.createTask("G", "E", "test9", "2015/10/23 18:23:10", 1));
    tm.addTask(TaskFactory.createTask("G", "A", "test10", "2015/10/22 17:23:20", 1));

    while (true) {
      Thread.sleep(5000); // query task progress every 5 seconds.
      tm.queryTaskState();
    }

  }
}
